package com.breezelin.freshmarket.entities.data;

/**
 * Created by Breeze Lin
 * 10:23 2016/5/15
 * 1linyufeng1@gmail.com
 */

import com.breezelin.freshmarket.entities.JsonStruct;

import org.json.JSONObject;

/**
 * 产品
 */
public class Product implements JsonStruct {

    /**
     * 产品id
     */
    private String commodityId;
    /**
     * 产品代码
     */
    private String commodityCode;
    /**
     * 产品名
     */
    private String commodityName;
    /**
     * 产品状态 todo 了解产品状态常数
     */
    private String state;
    /**
     * 产品状态文本
     */
    private String stateText;
    /**
     * 原价
     */
    private String originalPrice;
    /**
     * 商品价格
     */
    private String commodityPrice;
    /**
     * 产品规格
     */
    private String spec;
    /**
     * todo 未知字段
     */
    private String brandName;
    /**
     * 小图标
     */
    private String smallPic;
    /**
     * 是否显示原价
     */
    private String showOriginalPrice;
    /**
     * 最多可购买量
     */
    private String maxLimitCount;
    /**
     * 副标题
     */
    private String subTitle;
    /**
     * 产品标签 todo 了解产品标签类型
     */
    private String commodityTag;
    /**
     * 产品标签图
     */
    private String commodityTagPicture;

    public Product() {
    }

    public Product(JSONObject jsonObject) {
        fromJson(jsonObject);
    }

    public String getCommodityId() {
        return commodityId;
    }

    public String getCommodityCode() {
        return commodityCode;
    }

    public String getCommodityName() {
        return commodityName;
    }

    public String getState() {
        return state;
    }

    public String getStateText() {
        return stateText;
    }

    public String getOriginalPrice() {
        return originalPrice;
    }

    public String getCommodityPrice() {
        return commodityPrice;
    }

    public String getSpec() {
        return spec;
    }

    public String getBrandName() {
        return brandName;
    }

    public String getSmallPic() {
        return smallPic;
    }

    public boolean showOriginalPrice() {
        return showOriginalPrice.equals("1");
    }

    public String getMaxLimitCount() {
        return maxLimitCount;
    }

    public String getSubTitle() {
        return subTitle;
    }

    public String getCommodityTag() {
        return commodityTag;
    }

    public String getCommodityTagPicture() {
        return commodityTagPicture;
    }

    @Override
    public void fromJson(JSONObject jsonObject) {
        commodityId = jsonObject.optString("CommodityId");
        commodityCode = jsonObject.optString("CommodityCode");
        commodityName = jsonObject.optString("CommodityName");
        state = jsonObject.optString("State");
        stateText = jsonObject.optString("StateText");
        originalPrice = jsonObject.optString("OriginalPrice");
        commodityPrice = jsonObject.optString("CommodityPrice");
        spec = jsonObject.optString("Spec");
        brandName = jsonObject.optString("BrandName");
        smallPic = jsonObject.optString("SmallPic");
        showOriginalPrice = jsonObject.optString("ShowOriginalPrice");
        maxLimitCount = jsonObject.optString("MaxLimitCount");
        subTitle = jsonObject.optString("SubTitle");
        commodityTag = jsonObject.optString("CommodityTag");
        commodityTagPicture = jsonObject.optString("CommodityTagPicture");
    }

    @Override
    public JSONObject toJson() {
        return new JSONObject();
    }
}
